The objective of this notebook is to analyze the subjective bias of news from the main Brazilian newspapers….
require(GGally, quietly = TRUE)
require(reshape2, quietly = TRUE)
require(tidyverse, quietly = TRUE, warn.conflicts = FALSE)
## ── Attaching packages ─────────────────────────────────────── tidyverse 1.2.1 ──
## ✔ tibble 2.1.1 ✔ purrr 0.3.2
## ✔ tidyr 0.8.3 ✔ dplyr 0.8.0.1
## ✔ readr 1.3.1 ✔ stringr 1.4.0
## ✔ tibble 2.1.1 ✔ forcats 0.4.0
## ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
## ✖ dplyr::filter() masks stats::filter()
## ✖ dplyr::lag() masks stats::lag()
library(ggfortify)
library(cluster)
library(ggdendro)
library(broom)
library(tidyverse)
library(plotly)
##
## Attaching package: 'plotly'
## The following object is masked from 'package:ggplot2':
##
## last_plot
## The following object is masked from 'package:stats':
##
## filter
## The following object is masked from 'package:graphics':
##
## layout
options(warn=-1) # ignore warns
data <- read.csv("data/news_bias_formatted.csv",encoding="UTF-8")
data <- data %>%
filter(arg >= 0, sen >= 0, val >= 0, pre >= 0, mod >= 0)
O gráfico abaixo exibe a relação entre a variância acumulada nos PCAs com a variância total existente nos dados originais. Com 3 PC’s quase 90% da informação original dos dados é representada.
pr.out <- prcomp(select(data, arg, sen, val, pre, mod), scale = FALSE)
tidy(pr.out, "pcs") %>%
ggplot(aes(x = PC, y = cumulative)) +
geom_line(color = "blue") +
geom_point(color = "red") +
labs(x = "PCA's",
y = "Percentual de Representatividade")
Os vetores mostram a relação entre PC1, PC2 e as variáveis. O alinhamento entre os vetores arg e o eixo PC1 indica que as variáveis geratrizes deste vetore variam bastante para pontos que estão mais a esquerda ou a direita do gráfico. Ou seja, o eixo PC1 arg, quanto mais a esquerda o ponto estiver menor são seus valores para arg, quanto mais a direita maior serão esses valores.
autoplot(pr.out, data = data, size = 1,
loadings = TRUE, loadings.colour = 'blue',
loadings.label = TRUE,
loadings.label.size = 6 )
data %>%
filter() %>%
select(arg, sen, val, pre, mod) %>%
ggpairs()
plot_ly(type = 'parcoords',
lline = list(color = ~data$section,
colorscale = 'Jet',
showscale = TRUE,
reversescale = TRUE,
cmin = -4000,
cmax = -100),
dimensions = list(
list(label = 'Arumentação', values = ~data$arg),
list(label = 'Sentimento', values = ~data$sen),
list(label = 'Valoração', values = ~data$val),
list(label = 'Moduralização', values = ~data$mod),
list(label = 'Preposição', values = ~data$pre)
)
)